﻿if exists (select name from sysobjects where name = 'vYearlyReport' and type = 'V')
drop View vYearlyReport

Go

USE [NPMonitor]
GO

CREATE VIEW [dbo].[vYearlyReport]
AS
SELECT BeginTime,avg(Time) AS AverageTime,LocationId,ScenarioNO
FROM (
		SELECT  PoolId AS LocationId, ScenarioNO,
		CAST((CONVERT(VARCHAR(7), BeginTimeFormat, 120) + '-01 00:00:00') AS DATETIME) AS BeginTime,
		Time FROM  dbo.HttpActions 
	) AS T WHERE T.ScenarioNO != ''
GROUP BY BeginTime,LocationId,ScenarioNO;







GO
